import { debug } from 'webpack'
import { AppModel } from '../../../../model/AppModel'
import { createPartMenu, createVarMenu } from '../BlockPackage'

declare var Vue : any


export default {

    category: Blockly.Categories.bepart ,
    
    color: [
        Blockly.Colours.bepart.primary,
        Blockly.Colours.bepart.secondary,
        Blockly.Colours.bepart.tertiary
    ] ,

    previousStatement: true ,
    nextStatement: true ,
    inputsInline: false,

    init(model:Model, scratch3:any) {
        this.appendDummyInput()
            .appendField("数据解包")
        this.appendValueInput("var")
        this.appendStatementInput("dataraw")
    } ,

    run (args: any, util: any, runtime: any, model: AppModel) {
    } ,

    coder: {
        JavaScript(block: any, coder: any, model: AppModel) {
            let indent = coder.indentString()
            let datavar = coder.valueToCode(block, 'var', coder.ORDER_ASSIGNMENT) || '0'
            let code = `${indent}var _pkg_buff = ${datavar}\n`
            code+= `${indent}var _pkg_offset = 0\n`
            code+= `\n`
            code+= coder.statementToCode(block, 'dataraw');
            return code
        }
    }
}
